﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Polenter.Serialization;

namespace ZCrawler
{
    public static class ZBinaryWriter
    {
        public static void Serialize(object Obj,string fname)
        {
            using(FileStream fs = new FileStream(fname,FileMode.Create))
            {
                SharpSerializer serializer = new SharpSerializer(false);
                serializer.Serialize(Obj,fs);
            }
        }
        public static T Deserialize<T>(string fname)
        {
            T obj = default(T);
            using(FileStream fs = new FileStream(fname,FileMode.Open))
            {
                SharpSerializer serializer = new SharpSerializer(false);
                obj = (T)serializer.Deserialize(fs);
            }
            return obj;
        }
    }
}
